#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;


int main(int argc, char *argv[]) {
	if(argc!=3) {
		printf("Error number of arguments!\n");
		return 1;
	}
	FILE *f1 = fopen(argv[1], "r");
	FILE *f2 = fopen(argv[2], "r");
	if(f1==NULL || f2==NULL) {
		printf("Cannot open files!\n");
		return 1;
	}
	double d = 0, da, db;
	int c = 0;
	while(1) {
		double a, b;
		int t1=fscanf(f1, "%lf", &a);
		int t2=fscanf(f2, "%lf", &b);
		if(t1<1 && t2<1) break;
		if(t1<1 || t2<1) {
			printf("Different number of doubles!\n");
			break;
		}
		double d1 = fabs(a-b);
		double d2 = d1 / max(max(fabs(a), fabs(b)), 1.);
		if(d <= d2) {
			da=a, db=b;
		}
		d = max(d, d2);
		++c;
	}
	printf("check %d doubles: max diff=%.9lf%%\n", c, d*100.);
	printf("   a=%.9lf\n", da);
	printf("   b=%.9lf\n", db);
	return 0;
}
